<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="UTF-8">
	   <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	    <title>易支付</title>    
	    <link rel="stylesheet" href="../../css/mui.min.css" />
	    <link rel="stylesheet" href="../../css/own.css" />
	    <script type="text/javascript" src="../../js/mui.min.js"></script>  
	    <script type="text/javascript" src="../../js/common.js"></script>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav own-topbg">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" id="back"><i>返回</i></a>
			<h1 class="mui-title">易支付充值</h1>		
			<a href="javascript:void(0)" class="top-tel" id="telBtn">客服热线</a>
		</header>
	</body>
	<script type="text/javascript" charset="utf-8">
			
		//定义主页面和子页面对象
		var ws=null,embed=null; 
		
		// 扩展API加载完毕，现在可以正常调用扩展API
		function plusReady(){
			ws = plus.webview.currentWebview(); 
			//ws.addEventListener('show',createEmbed(ws.mobilePayUrl,ws.merchantaccount,ws.data,ws.encryptkey),false);
			
			ws.addEventListener('show',createEmbed(ws.payurl,ws.vamount,ws.vmd5info,ws.vmid,ws.vmoneytype,ws.vordername,
				ws.vorderstatus,ws.vorid,ws.vpmode,ws.vrcvaddr,ws.vrcvname,ws.vrcvpost,ws.vrcvtel,ws.vurl,ws.vymd),false);
			
			tzdr.init.initHearListener(); 
		}
		
		// 判断扩展API是否准备，否则监听"plusready"事件
		if(window.plus){
			plusReady();
		}else{
			document.addEventListener("plusready",plusReady,false);
		}
		
			// 创建子Webview
		function createEmbed(payurl,vamount,vmd5info,vmid,vmoneytype,vordername,vorderstatus,vorid,
							vpmode,vrcvaddr,vrcvname,vrcvpost,vrcvtel,vurl,vymd){ 
			var topoffset='45px';
			if(plus.navigator.isImmersedStatusbar()){// 兼容immersed状态栏模式
				topoffset=(Math.round(plus.navigator.getStatusbarHeight())+45)+'px'; 
			}
			plus.nativeUI.showWaiting('',{style:'black',modal:false,background:'rgba(0,0,0,0)'});
			 var payParams = {"payurl":payurl,"vamount":vamount,"vmd5info":vmd5info,
						 "vmid":vmid,"vmoneytype":vmoneytype,"vordername":vordername,
						 "vorderstatus":vorderstatus,"vorid":vorid,"vpmode":vpmode,
						 "vrcvaddr":vrcvaddr,"vrcvname":vrcvname,"vrcvpost":vrcvpost,
						 "vrcvtel":vrcvtel,"vurl":vurl,"vymd":vymd};
			embed=plus.webview.create('easepay.html','easepay.html',{top:topoffset,bottom:'0px',position:'dock',dock:'bottom',bounce:'vertical'},payParams);
			ws.append(embed);
			embed.addEventListener('loaded',function(){
				plus.nativeUI.closeWaiting();
			},false);
			embed.addEventListener('loading',function(){
				plus.nativeUI.showWaiting('',{style:'black',modal:false,background:'rgba(0,0,0,0)'});
			},false);
		}
		
		
		// 创建子Webview
		/*function createEmbed(_bbpay_service_url,_bbpay_merchantaccount,_bbpay_data,_bbpay_encryptkey){
			var topoffset='45px';
			if(plus.navigator.isImmersedStatusbar()){// 兼容immersed状态栏模式
				topoffset=(Math.round(plus.navigator.getStatusbarHeight())+45)+'px'; 
			}
			plus.nativeUI.showWaiting('',{style:'black',modal:false,background:'rgba(0,0,0,0)'});
			embed=plus.webview.create('bbpay.html','bbpay.html',{top:topoffset,bottom:'0px',position:'dock',dock:'bottom',bounce:'vertical'},{mobilePayUrl:_bbpay_service_url,merchantaccount:_bbpay_merchantaccount,data:_bbpay_data,encryptkey:_bbpay_encryptkey});
			ws.append(embed);
			embed.addEventListener('loaded',function(){
				plus.nativeUI.closeWaiting();
			},false);
			embed.addEventListener('loading',function(){
				plus.nativeUI.showWaiting('',{style:'black',modal:false,background:'rgba(0,0,0,0)'});
			},false);
		}*/ 
		
		// 打开网址
		function openUrl(){
			var url=document.getElementById("url");
			embed.loadURL(url.value);
			url.blur();
		}
		
		// 页面加载后自动打开
		document.addEventListener("DOMContentLoaded",function(){
			if(embed){
				openUrl();
			}else{
				auto=true;
			}
		},false);
		
		// 页面跳转完成事件
		function onBrowserLoading(){
			document.getElementById("url").value=embed.getURL();
		}
	</script>
</html>